/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package RestaurantManagement.oop.demo.restaurantmanagementsystem;

/**
 * Abstract class that provides structure
 * for the billing system
 * @author ashongtical
 */

import java.util.ArrayList;

public abstract class RestaurantBillingSystem {
    //Allow subclass direct access, so that I choose use "protected".
    protected ArrayList<Meal> menu;

    //Constructor to initialize the menu
    public RestaurantBillingSystem() {
        this.menu = new ArrayList<>();
    }

    //Add a meal to the menu
    //meal: The meal to add
    public void addMeal(Meal meal) {
        this.menu.add(meal);
        System.out.println("Meal '"+meal.getName()+"'"+" added to menu.");
    }

    //Remove a meal from the menu by name
    //mealName The name of the meal to remove
    //return true if meal was removed, false otherwise
    public boolean removeMeal(String mealName) {
        Meal meal = findMealByName(mealName);
        if (meal != null) {
            this.menu.remove(meal);
            System.out.println("Meal '"+mealName+"' removed from menu.");
            return true;
        }
        System.out.println("Meal '"+mealName+"' not found in the menu.");
        return false;
    }

    //Find a meal on the menu by name
    //mealName: The name of the meal to find
    //The meal if found, null otherwise
    public Meal findMealByName(String mealName) {
        for (Meal meal : menu) {
            if (meal.getName().equals(mealName)) {
                return meal;
            }
        }
        return null;
    }

    //Abstract method for adding a meal for an order
    //mealName The name of the meal to add to the order
    // return boolean indicating success or failure
    public abstract boolean addMealToOrder(String mealName);


    //Abstract method for calculating the bill
    //return The total bill amount
    public abstract double calculateBill();

}
